import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

#  {darkgrid, whitegrid, dark, white, ticks}

if __name__ == '__main__':
    sns.set_style('whitegrid')
    axs = plt.figure()

    with sns.axes_style("whitegrid"):
        axs2 = axs.add_subplot(2, 2, 1)
        axs2.plot(np.random.randint(1, 6, 6), np.linspace(1, 5, 6))

        axs1 = axs.add_subplot(2, 2, 2)
        axs1.plot([x for x in range(6)], [x for x in range(6, 0, -1)])

    # 设置主题作用域
    with sns.axes_style("darkgrid"):
        x = np.linspace(1, 3, 30)
        y = np.square(x) + np.random.uniform(-0.1, 0.1, 30)
        axs1 = axs.add_subplot(2, 2, 3)
        axs1.scatter(x, y, c='y')

    with sns.axes_style("dark"):
        x = np.linspace(1, 3, 30)
        # sin 函数
        axs4 = axs.add_subplot(2, 2, 4)
        axs4.plot(x, np.sin(x*4))

        # 删除边框 offset设置轴线
        sns.despine(offset=2)

    plt.show()
